# eric7.UI.DiffDialog

Module implementing a dialog to compare two files.

### Global Attributes

None

### Classes

DiffDialog | Class implementing a dialog to compare two files.
DiffWindow | Main window class for the standalone dialog.

### Functions

None

## DiffDialog

Class implementing a dialog to compare two files.

### Derived from

QWidget, Ui_DiffDialog

### Class Attributes

None

### Class Methods

None

### Methods

DiffDialog | Constructor
__appendText | Private method to append text to the end of the contents pane.
__fileChanged | Private slot to enable/disable the Compare button.
__generateContextDiff | Private slot to generate a context diff output.
__generateUnifiedDiff | Private slot to generate a unified diff output.
on_buttonBox_clicked | Private slot called by a button of the button box clicked.
on_diffButton_clicked | Private slot to handle the Compare button press.
on_saveButton_clicked | Private slot to handle the Save button press.
show | Public slot to show the dialog.

### Static Methods

None

#### DiffDialog (Constructor)

DiffDialog(files=None, parent=None)

Constructor

files (list of [str, str])
  list of two file names to be diffed
parent (QWidget)
  reference to the parent widget

#### DiffDialog.__appendText

__appendText(txt)

Private method to append text to the end of the contents pane.

txt (str)
  text to insert

#### DiffDialog.__fileChanged

__fileChanged()

Private slot to enable/disable the Compare button.

#### DiffDialog.__generateContextDiff

__generateContextDiff(a, b, fromfile, tofile, fromfiledate, tofiledate)

Private slot to generate a context diff output.

a (list of str)
  first sequence of lines
b (list of str)
  second sequence of lines
fromfile (str)
  filename of the first file
tofile (str)
  filename of the second file
fromfiledate (str)
  modification time of the first file
tofiledate (str)
  modification time of the second file

#### DiffDialog.__generateUnifiedDiff

__generateUnifiedDiff(a, b, fromfile, tofile, fromfiledate, tofiledate)

Private slot to generate a unified diff output.

a (list of str)
  first sequence of lines
b (list of str)
  second sequence of lines
fromfile (str)
  filename of the first file
tofile (str)
  filename of the second file
fromfiledate (str)
  modification time of the first file
tofiledate (str)
  modification time of the second file

#### DiffDialog.on_buttonBox_clicked

on_buttonBox_clicked(button)

Private slot called by a button of the button box clicked.

button (QAbstractButton)
  button that was clicked

#### DiffDialog.on_diffButton_clicked

on_diffButton_clicked()

Private slot to handle the Compare button press.

#### DiffDialog.on_saveButton_clicked

on_saveButton_clicked()

Private slot to handle the Save button press.

It saves the diff shown in the dialog to a file in the local filesystem.

#### DiffDialog.show

show(filename=None)

Public slot to show the dialog.

filename (str)
  name of a file to use as the first file

Up

## DiffWindow

Main window class for the standalone dialog.

### Derived from

EricMainWindow

### Class Attributes

None

### Class Methods

None

### Methods

DiffWindow | Constructor
eventFilter | Public method to filter events.

### Static Methods

None

#### DiffWindow (Constructor)

DiffWindow(files=None, parent=None)

Constructor

files (list of [str, str])
  list of two file names to be diffed
parent (QWidget)
  reference to the parent widget

#### DiffWindow.eventFilter

eventFilter(_obj, event)

Public method to filter events.

_obj (QObject)
  reference to the object the event is meant for (unused)
event (QEvent)
  reference to the event object

Return:
  flag indicating, whether the event was handled

Return Type:
  bool

Up